<template>
  <div>
    <vtour />
    <div class="zs_nav_main">
      <div class="navsMain">
        <div
          class="zs_nav_li"
          v-for="(item, index) in navBar"
          :class="{ zs_nav_li_sel: index === navNum }"
          @click="navClick(index)"
        >
          {{ item.name }}
        </div>
      </div>
    </div>
    <div class="search-box box-main">
      <div class="title" @click="isshowSel">
        选择村庄 <span class="isshow" ></span>
      </div>
      <div class="box">{{currentName}}</div>
    </div>
    <div class="select-main" v-show="isshow">
      <select-main @receive="receive" @close-curr="closeCurr"/>
    </div>
    <router-view ref="super"></router-view>
  </div>
</template>

<script>
import Vtour from "components/content/vtour/Vtour.vue";
import SelectMain from "components/content/selectMain/SelectMain.vue";
export default {
  components: { Vtour, SelectMain },
  data() {
    return {
      navBar: [
        {
          name: "人口",
          path: "/peoples",
        },
        {
          name: "土地",
          path: "/territory",
        },
        {
          name: "产业监测",
          path: "/industry",
        },
        {
          name: "党建",
          path: "/partyBuilding",
        },
        {
          name: "人居环境",
          path: "/environment",
        },
        {
          name: "安防",
          path: "/security",
        },
      ],
      navNum: 0,
      isshow: false,
      currentName:'',
      pano:null
    };
  },
  mounted() {
    this.bus.$on("scene-click", (scene) => {
      this.receive(scene);
      this.$refs.super.refurbish(scene.id)
    });
  },
  created() {
    this.currentName = JSON.parse(sessionStorage.getItem('pano')).name
  },
  methods: {
    navClick(index) {
      this.navNum = index;
      this.$router.push("/main/ksy/ksyMain" + this.navBar[index].path);
    },
    receive(spot) {
      this.currentName = spot.name;
      window.krpano.call("loadscene(" + spot.scene + ",null,MERGE,BLEND(1));");
    },
    setcurrent() {
      return this.$store.state.currentName == '' ? JSON.parse(sessionStorage.getItem('pano')).name :  this.$store.state.currentName
    },
    isshowSel() {
      this.isshow = !this.isshow;
    },
    closeCurr() {
      this.isshow = false
    }
  },
  beforeDestroy() {
    this.bus.$off("scene-click");
  },
};
</script>

<style lang="scss" scoped>
@import url("~assets/css/box.scss");
.zs_nav_main {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-transform: translateX(-50%);
  -moz-transform: translateX(-50%);
  -ms-transform: translateX(-50%);
  -o-transform: translateX(-50%);
  width: 109rem;
  height: 4.1875rem;
  background: url(~assets/img/ksh/selbg.png) no-repeat;
  background-position: center;
  background-size: 100% 100%;
  .navsMain {
    display: flex;
    .zs_nav_li {
      box-sizing: border-box;
      background: url(~assets/img/ksh/nav.png) no-repeat;
      background-size: 100% 100%;
      text-align: center;
      width: 6.5625rem;
      line-height: 2rem;
      margin: 0 0.3125rem;
      cursor: pointer;
    }
    .zs_nav_li:hover {
      background: url(~assets/img/ksh/nav_sel.png) no-repeat;
      background-size: 100% 100%;
    }
    .zs_nav_li_sel {
      background: url(~assets/img/ksh/nav_sel.png) no-repeat;
      background-size: 100% 100%;
    }
  }
}
.search-box {
  position: fixed;
  top: 5rem;
  left: 1.25rem;
  z-index: 123;
  width: 25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem;
  .box {
    height: 3.125rem;
    color: #fff;
    font-size: 1rem;
    padding-top: 0.625rem;
  }
  .title {
    padding-right: 3.75rem;
    position: relative;
    .isshow {
      cursor: pointer;
      background: url(~assets/img/ksh/pull2.png) no-repeat;
      background-size: 100%;
      transform: rotateZ(-90deg);
      display: inline-block;
      width: 0.6875rem;
      height: 0.375rem;
      position: absolute;
      right: 3.75rem;
      top: 0.5rem;
    }
  }
}
.select-main {
  position: fixed;
  top: 5rem;
  left: 28.125rem;
}
</style>